Skip to content

Only copy files not ignored by git for local build #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

vpratz
Copy link
Contributor

@vpratz vpratz commented Mar 2, 2025

Closes #30.

Using git ls-files --cached --others --exclude-standard, we can obtain all files that are not ignored by git. This will also include files that are not checked in. We can use this list to only copy non-ignored files for local builds, which can significantly speed up the build process when large ignored files/directories are present in the working directory.

This PR tries to use the git command, and falls back to a full copy in case of errors.

vpratz added 3 commits March 2, 2025 10:35
Fixes real-yfprojects#26.

The following error message arises when using `setuptools-scm`:

```
LookupError: setuptools-scm was unable to detect version for ...

      Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

      For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

      Alternatively, set the version with the environment variable SETUPTOOLS_SCM_PRETEND_VERSION_FOR_${NORMALIZED_DIST_NAME} as described in https://setuptools-scm.readthedocs.io/en/latest/config.
      [end of output]
```

This can be resolved by creating an empty git respository.
@vpratz
Copy link
Contributor Author

vpratz commented Mar 2, 2025

Do you think this requires further documentation? Or is the info in the log sufficient?

Copy link
Owner

@real-yfprojects real-yfprojects left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I like this approach as we don't have to maintain any code implementing the gitignore specifications.
However it seems like git ls-files --others doesn't support submodules, so this is something we need to think about.
Currently the code changes do not fit into the modular architecture of this project. As we cannot expect everyone to use git, this has to be hidden behind some level of abstraction. In this case I think it would be best to add a checkout_local or similarly named method to vcs.VersionProvider that is called by the driver.
Lastly, can you remove the commits from #29 that slipped into this PR? (e.g. using git rebase -i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Respect gitignore when copying files in DefaultDriver.build_local
2 participants